package com.good.jzhouse.dao;

import com.good.jzhouse.bean.PayRecord;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface PayRecordDao {

    @Select("select * from PayRecord limit #{page},#{limit}")
    List<PayRecord> findAll(@Param("page") Integer page,@Param("limit") Integer limit);

    @Select("select * from PayRecord where userId=#{id} limit #{page},#{limit}")
    List<PayRecord> findAllbyid(@Param("id")Integer id,@Param("page") Integer page,@Param("limit") Integer limit);

    @Select("select * from PayRecord where pid=#{id} ")
    PayRecord selectById( @Param("id") Integer id);

    @Update("update PayRecord set paymentBalance=#{paymentBalance},paymentWay=#{paymentWay},rechargeRemark=#{rechargeRemark}," +
            "rechargeIp=#{rechargeIp},rechargeTime=#{rechargeTime},#{user.uid} where pid=#{pid}")
    int update(PayRecord payRecord);

    @Insert("insert into PayRecord values(null,#{paymentBalance},#{paymentWay},#{rechargeRemark},#{rechargeIp},#{rechargeTime},#{user.uid})")
    int insert(PayRecord payRecord);

    @Delete("delete from PayRecord where pid=#{pid}")
    int del(@Param("pid")Integer pid);

    @Select("select count(*) from PayRecord")
    int count();

    @Select("select count(*) from PayRecord where userId=#{id}")
    int countbyid(Integer id);
}
